/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __XOS_CORE_OS_MUTEX_H__
#define __XOS_CORE_OS_MUTEX_H__

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace xos
{

    class mutex
    {
    public:
        mutex()
        {
            pthread_mutex_init( &m_mutex, 0 );
        }
        ~mutex()
        {
            pthread_mutex_destroy( &m_mutex );
        }

    protected:
        pthread_mutex_t m_mutex;

    public:
        int un_lock()
        {
            int nRet = 0;
            pthread_mutex_unlock( &m_mutex );
            return nRet;
        }
        int lock()
        {
            int nRet = 0;
            pthread_mutex_lock( &m_mutex );
            return nRet;
        }
    };

} // xos

#endif // __XOS_CORE_OS_MUTEX_H__
